<!DOCTYPE html>
<html>
<head>
    {include file='public/meta'/}
</head>
<body>

{include file='public/header'/}
<!------------------导航-------------------------->
<section>
    {include file='public/left'/}
    <!--------------------------主要内容区域------------------------------------->
    <div class="content">
        <div class="page-heading mgl15 mgr15">
            <ul class="breadcrumb">
                <li>当前位置是&nbsp;:&nbsp;</li>
                <li><a href="#">微信管理</a></li>
                <li class="active" style="color: #02b87f;"> 发布小程序</li>
            </ul>
        </div>
        <div class="panel panel-default mgl15 mgr15">
            <div class="panel-body">

                <div id="myTabContent" class="tab-content">
                    <div class="tab-pane active in" id="home">
                        <div class="alert alert-danger" role="alert">
                            请绑定授权绑定小程序后开始设置。以下参数请勿修改
                        </div>


                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title">第一步：设置小程序基本信息</h3>
                            </div>
                            <div class="panel-body">
                                <form class="form-horizontal" name="form" id="frm1" style="max-width: 900px;">
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">商家小程序Appid：</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" placeholder="" name="extAppid"
                                                   value="{$wx_open['authorizer_appid']}" readonly="readonly">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">小程序模板id：</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" placeholder="" name="template_id"
                                                   value="{$xcxset['template_id']}">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">入口页面：</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" placeholder="" name="extPages"
                                                   value="{$xcxset['extpages']}">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">代码版本号：</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" placeholder="" name="user_version"
                                                   value="{$xcxset['user_version']}" readonly="readonly">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">代码描述：</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" placeholder="" name="user_desc"
                                                   value="{$xcxset['user_desc']}" readonly="readonly">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">服务器域名：</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" placeholder="" name="siteurl"
                                                   value="{$siteurl}" readonly="readonly">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">会员卡ID：</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" placeholder="" name="card_id"
                                                   value="{$card_id}" readonly="readonly">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">请求URL：</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" placeholder="" name="weburl"
                                                   value="{$xcxset['weburl']}" readonly="readonly">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">商户ID：</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" placeholder="" name="merchid"
                                                   value="{$merchid}" readonly="readonly">
                                        </div>
                                    </div>
                                    <div class="form-group text-center">
                                        <span class="btn btn-default" id="sethy">设置</span>
                                    </div>
                                </form>

                            </div>
                        </div>
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title">第二步：获取体验二维码</h3>
                            </div>
                            <div class="panel-body">

                                <div class="form-group">

                                    <div class="col-sm-12" id="qrdiv" style="display: none">
                                        <img id="qrcode" src="">
                                    </div>
                                </div>
                                <div class="form-group text-center">
                                    <span class="btn btn-default" id="getqrcode">获取</span>
                                </div>


                            </div>
                        </div>
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title">第三步：提交审核</h3>
                            </div>
                            <div class="panel-body">
                                <form class="form-horizontal" name="form" id="frm2" style="max-width: 900px;">
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">标签（空格分割）：</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" placeholder="" name="tag"
                                                   value="">
                                        </div>
                                    </div>
                                    <div class="form-group text-center">
                                        <span class="btn btn-default" id="setyw">提交审核</span>
                                        <span class="btn btn-default" id="chsh">撤回审核</span>
                                    </div>
                                </form>

                            </div>
                        </div>
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title">第四步：设置小程序可见状态</h3>
                            </div>
                            <div class="panel-body">
                                <div class="form-group">
                                    <div style="text-align: center;color: red">当前可见状态：
                                        {switch name="xcxstatu"}
                                        {case value="0"}可被搜索{/case}
                                        {case value="1"}不可被搜索{/case}
                                        {default /}default
                                        {/switch}
                                        </div>
                                </div>
                                <div style="text-align: center">
                                <form class="form-horizontal" name="form" id="frm3" style="max-width: 100%;">
                                    <div class="form-group">
                                        <label for="name">选择状态</label>
                                        <div class="col-sm-12">
                                        <select class="form-control" name="status">
                                            <option value="0">可被搜索</option>
                                            <option value="1">不可被搜索</option>
                                        </select>
                                        </div>
                                    </div>
                                    <div class="form-group text-center">
                                        <span class="btn btn-default" id="setyw3">设置</span>
                                    </div>
                                </form>
                                </div>
                            </div>
                        </div>
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title">审核列表</h3>
                            </div>
                            <table class="table table-bordered">

                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>小程序审核ID</th>
                                    <th>添加时间</th>
                                    <th>审核状态</th>
                                    <th>审核时间</th>
                                    <th>审核情况</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {volist name="xcxinfo" id="vo" key="k"}
                                <tr>
                                    <td>{$k}</td>
                                    <td>{$vo['auditid']}</td>
                                    <td>{$vo['addtime']|date="Y-m-d H:i:s",###}</td>
                                    <td>
                                        {switch name="vo.status"}
                                        {case value="0"}审核成功{/case}
                                        {case value="1"}审核失败{/case}
                                        {case value="2"}审核中{/case}
                                        {default /}default
                                        {/switch}
                                    </td>
                                    <td>{if condition="$vo['shtime'] neq ''"}{$vo['shtime']|date="Y-m-d
                                        H:i:s",###}{/if}
                                    </td>
                                    <td>{$vo.reason}</td>
                                    <td>{if condition="$vo['status'] eq '2'"}<a onclick="cx({$vo['auditid']})">查询审核状态</a>{/if}
                                    </td>
                                </tr>
                                {/volist}

                                </tbody>
                            </table>
                        </div>
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title">发布审核通过的小程序</h3>
                            </div>
                            <p></p>

                            <div class="form-group text-center">
                                <span class="btn btn-default" onclick="fb()">发布小程序</span>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
        {include file='public/footer'/}
    </div>
</section>

</body>

<script>
    function fb(){
        $.ajax({
            url: "{:url('microprogram/xcx_release')}",
            type: "post",
            data: {
            },
            success: function (data) {


                layer.msg(data.message, {icon: 1});
                setTimeout("window.location.href=window.location.href", 2000);

                return false;

            }
        })

    }
    function cx(auditid) {
        $.ajax({
            url: "{:url('microprogram/xcx_getauditstatus')}",
            type: "post",
            data: {
                'auditid': auditid
            },
            success: function (data) {


                layer.msg(data.message, {icon: 1});
                setTimeout("window.location.href=window.location.href", 2000);

                return false;

            }
        })

    }

    $(function () {
        $("#sethy").click(function () {
            layer.confirm('是否设置？', {
                btn: ['确认', '取消'] //按钮
            }, function () {
                $.ajax({
                    url: "{:url('microprogram/sub_program')}",
                    type: "post",
                    data: $('#frm1').serialize(),
                    success: function (data) {
                        // console.log(data);
                        if (data.code == "0") {

                            layer.msg("操作成功", {icon: 1});
                            setTimeout("window.location.href=window.location.href", 2000);
                            return false;
                        } else {
                            layer.alert("操作失败  " + data.code + "   " + data.message, {icon: 7});
                        }
                    }
                })
            }, function () {
                layer.msg('您已取消!', {
                    time: 500, //20s后自动关闭
                });
            });

        })
        $("#chsh").click(function () {
            layer.confirm('是否设置？', {
                btn: ['确认', '取消'] //按钮
            }, function () {
                $.ajax({
                    url: "{:url('microprogram/xcx_uncode')}",
                    type: "post",
                    data: {},
                    success: function (data) {
                        // console.log(data);
                        if (data.code == "0") {

                            layer.msg("操作成功", {icon: 1});
                            setTimeout("window.location.href=window.location.href", 2000);
                            return false;
                        } else {
                            layer.alert("操作失败  " + data.code + "   " + data.message, {icon: 7});
                        }
                    }
                })
            }, function () {
                layer.msg('您已取消!', {
                    time: 500, //20s后自动关闭
                });
            });

        })
        $("#getqrcode").click(function () {

            $.ajax({
                url: "{:url('microprogram/getqrcode')}",
                type: "post",
                data: $('#frm1').serialize(),
                success: function (data) {

                    $('#qrdiv').css('display', 'inline');
                    $('#qrcode').attr('src', data);
                }
            })

        })
        $("#setyw").click(function () {
            layer.confirm('是否设置？', {
                btn: ['确认', '取消'] //按钮
            }, function () {
                $.ajax({
                    url: "{:url('microprogram/sub_program_sh')}",
                    type: "post",
                    data: $('#frm2').serialize(),
                    success: function (data) {
                        // console.log(data);
                        if (data.code == "0") {

                            layer.msg("操作成功", {icon: 1});
                            setTimeout("window.location.href=window.location.href", 2000);
                            return false;
                        } else {
                            layer.alert("操作失败  " + data.code + "   " + data.message, {icon: 7});
                        }
                    }
                })
            }, function () {
                layer.msg('您已取消!', {
                    time: 500, //20s后自动关闭
                });
            });

        })
        $("#setyw3").click(function () {
            layer.confirm('是否设置？', {
                btn: ['确认', '取消'] //按钮
            }, function () {
                $.ajax({
                    url: "{:url('microprogram/set_xcx_search')}",
                    type: "post",
                    data: $('#frm3').serialize(),
                    success: function (data) {

                        if (data.code == "0") {

                            layer.msg("操作成功", {icon: 1});
                            setTimeout("window.location.href=window.location.href", 2000);
                            return false;
                        } else {
                            layer.alert("操作失败  " + data.code + "   " + data.message, {icon: 7});
                        }
                    }
                })
            }, function () {
                layer.msg('您已取消!', {
                    time: 500, //20s后自动关闭
                });
            });

        })
    })
</script>
</html>


